<template>
  <!--抽检意见  -->
  <div>
    <FormPanel
      ref="formPanel"
      :list="initForm"
      :cols="1"
      :formType="value.type"
      :labelWidth="110"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      formValue: {},
      slotCheckFromDB: ''
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    init() {
      if (this.value.type === 'edit') {
        this.initForm.forEach(x => {
          x.initialValue = this.value.row[x.fieldName];
          if (x.fieldName == 'slotCheck') {
            this.slotCheckFromDB = x.initialValue;
          }
        });
      }
    },
    saveDialog() {
      this.$refs.formPanel.SUBMIT_FORM();
    },
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'TEXT_AREA',
          label: '抽检意见',
          fieldName: 'slotCheck',
          initialValue: '',
          rules: [{ required: true, message: '请输入抽检意见', trigger: 'blur' }]
        }
      ];
    },
    formChangeHandle(val) {
      this.formValue = val;
      this.$emit('formchange', this.formValue);
    }
  },
  created() {
    this.init();
  }
};
</script>
